Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Imaging with QuickDraw

Previous | Chapter Top | Chapter Contents | Next |

Data Structures

This section shows the Pascal data structures for the Picture , OpenCPicParams , CommentSpec , FontSpec , and PictInfo records.

When you use the OpenCPicture or OpenPicture function, QuickDraw begins collecting your subsequent drawing commands in a Picture record. When you use the GetPicture function to retrieve a picture stored in a resource, GetPicture reads the resource into memory as a Picture record.

When you use the OpenCPicture function to begin creating a picture, you must pass it information in an OpenCPicParams record. This record provides a simple mechanism for specifying resolutions when creating images.

When you use the GetPictInfo function, it returns information in a PictInfo record. When you gather this information for multiple pictures, pixel maps, or bitmaps, the RetrievePictInfo function also returns a PictInfo record containing this information.

If you specify the recordComments constant in the verb parameter to the GetPictInfo function or NewPictInfo function, your application receives a PictInfo record that includes a handle to a CommentSpec record. A CommentSpec record contains information about the comments in a picture.

If you specify the recordFontInfo constant in the verb parameter to the GetPictInfo function or NewPictInfo function, the function returns a PictInfo record that includes a handle to a FontSpec record. A FontSpec record contains information about the fonts in a picture.

Picture

When you use the OpenCPicture or OpenPicture function (described on OpenCPicture and OpenPicture , respectively), QuickDraw begins collecting your subsequent drawing commands in a Picture record. (You use the ClosePicture procedure, described on ClosePicture , to complete a picture definition.) When you use the GetPicture function (described on GetPicture ) to retrieve a picture stored in a resource, GetPicture reads the resource into memory as a Picture record. ( 'PICT' resources are described on The Picture Resource .) By using the DrawPicture procedure (described on DrawPicture ), you can draw onscreen the picture defined by the commands stored in the Picture record.

A Picture record is defined as follows:

TYPE Picture =
RECORD
    picSize:        Integer;    {for a version 1 picture: its size}
    picFrame:       Rect;       {bounding rectangle for the picture}
    {variable amount of picture data in the form of opcodes}
END;
picSize
The size of the rest of this record for a version 1 picture. To maintain compatibility with the version 1 picture format, the picSize field was not changed for the version 2 picture or extended version 2 formats. The information in this field is useful only for version 1 pictures, which cannot exceed 32 KB in size. Because version 2 and extended version 2 pictures can be much larger than the 32 KB limit imposed by the 2-byte picSize field, you should use the Memory Manager function GetHandleSize to determine the size of a picture in memory, the File Manager function PBGetFInfo to determine the size of a picture in a 'PICT' file, and the Resource Manager function MaxSizeResource to determine the size of a 'PICT' resource. (See Inside Macintosh: Memory , Inside Macintosh: Files , and Inside Macintosh: More Macintosh Toolbox for more information about these functions.)
picFrame
The bounding rectangle for the picture defined in the rest of this record. The DrawPicture procedure uses this rectangle to scale the picture if you draw it into a destination rectangle of a different size.

Picture comments and compact drawing instructions in the form of picture opcodes compose the rest of this record.

A picture opcode is a number that the DrawPicture procedure uses to determine what object to draw or what mode to change for subsequent drawing. For debugging purposes, picture opcodes are listed in Appendix A at the back of this book. Your application generally should not read or write this picture data directly. Instead, your application should use the OpenCPicture (or OpenPicture ), ClosePicture , and DrawPicture routines to process these opcodes.

The Picture record can also contain picture comments. Created by applications using the PicComment procedure, picture comments contain data or commands for special processing by output devices, such as PostScript printers. The PicComment procedure is described on PicComment , and picture comments are described in greater detail in Appendix B in this book.

You can use File Manager routines to save the picture in a file of type 'PICT' , you can use Resource Manager routines to save the picture in a resource of type 'PICT' , and you can use the Scrap Manager procedure PutScrap to store the picture in 'PICT' scrap format. See the chapter "File Manager" in Inside Macintosh: Files and the chapters "Resource Manager" and "Scrap Manager" in Inside Macintosh: More Macintosh Toolbox for more information about saving files, resources, and scrap data .

OpenCPicParams

When you use the OpenCPicture function (described on OpenCPicture ) to begin creating a picture, you must pass it information in an OpenCPicParams record. This record provides a simple mechanism for specifying resolutions when creating images. For example, applications that create pictures from scanned images can specify resolutions higher than 72 dpi for these pictures in OpenCPicParams records.

An OpenCPicParams record is defined as follows:

TYPE OpenCPicParams =
RECORD
    srcRect:        Rect;           {optimal bounding rectangle for }
                                    { displaying picture at resolution }
                                    { indicated in hRes, vRes fields}
    hRes:           Fixed;          {best horizontal resolution; }
                                    { $00480000 specifies 72 dpi}
    vRes:           Fixed;          {best vertical resolution; }
                                    { $00480000 specifies 72 dpi}
    version:        Integer;        {set to -2}
    reserved1:      Integer;        {reserved; set to 0}
    reserved2:      LongInt;        {reserved; set to 0}
END;
srcRect
The optimal bounding rectangle for the resolution indicated by the next two fields. When you later call the DrawPicture procedure (described on DrawPicture ) to play back the saved picture, you supply a destination rectangle, and DrawPicture scales the picture so that it is completely aligned with the destination rectangle. To display a picture at a resolution other than that specified in the next two fields, your application should compute an appropriate destination rectangle by scaling its width and height by the following factor:
scale factor = destination resolution / source resolution
hRes
The best horizontal resolution for the picture. Notice that this value is of type Fixed --a value of $0048000 specifies a horizontal resolution of 72 dpi.
vRes
The best vertical resolution for the picture. Notice that this value is of type Fixed --a value of $00480000 specifies a horizontal resolution of 72 dpi.
version
Always set this field to -2.
reserved1
Reserved; set to 0.
reserved2
Reserved; set to 0.

CommentSpec

If you specify the recordComments constant in the verb parameter to the GetPictInfo function (described on GetPictInfo ) or the NewPictInfo function (described on NewPictInfo ), you receive a PictInfo record (described beginning on PictInfo ) that includes in its commentHandle field a handle to an array of CommentSpec records. The uniqueComments field of the PictInfo record indicates the number of CommentSpec records in this array.

The CommentSpec record is defined as follows:

TYPE CommentSpec =          {comment specification record}
RECORD
    count:      Integer;    {number of times this type of comment }
                            { occurs in the picture or survey}
    ID:         Integer;    {value identifying this type of comment}
END;
count
The number of times this kind of picture comment occurs in the picture specified to the GetPictInfo function or in all the pictures examined with the NewPictInfo function.
ID
The value set in the kind parameter when the picture comment was created with the PicComment procedure. The PicComment procedure is described on PicComment . The values of many common IDs are listed in Appendix B in this book.

When you are finished using the information returned in a CommentSpec record, you should use the DisposeHandle procedure (described in Inside Macintosh: Memory ) to dispose of the memory allocated to it.

Listing 7-12 illustrates how to count the number of picture comments by examining a CommentSpec record.

FontSpec

If you specify the recordFontInfo constant in the verb parameter to the GetPictInfo function (described on GetPictInfo ) or the NewPictInfo function (described on NewPictInfo ), your application receives a PictInfo record (described beginning on PictInfo ) that includes in its fontHandle field a handle to an array of FontSpec records. The uniqueFonts field of the PictInfo record indicates the number of FontSpec records in this array. (For bitmap fonts, a font is a complete set of glyphs in one size, typeface, and style--for example, 12-point Geneva italic. For outline fonts, a font is a complete set of glyphs in one typeface and style--for example, Geneva italic.)

The FontSpec record is defined as follows:

TYPE FontSpec =                 {font specification record}
RECORD
    pictFontID:     Integer;    {font ID as stored in the picture}
    sysFontID:      Integer;    {font family ID}
    size:           ARRAY[0..3] OF LongInt;
                                {each bit set from 1 to 127 indicates a }
                                { point size at that value; if bit 0 is }
                                { set, then a size larger than 127 }
                                { points is found}
    style:          Integer;    {styles used for this font family}
    nameOffset:     LongInt;    {offset to font name stored in the }
                                { data structure indicated by the }
                                { fontNamesHandle field of the PictInfo }
                                { record}
END;
pictFontID
The ID number of the font as it is stored in the picture.
sysFontID
The number that identifies the resource file (of type 'FOND' ) that specifies the font family. Every font family--which consists of a complete set of fonts for one typeface including all available styles and sizes of the glyphs in that typeface--has a unique font family ID, in a range of values that determines the script system to which the font family belongs.
size
The point sizes of the fonts in the picture. The field contains 128 bits, in which a bit is set for each point size encountered, from 1 to 127 points. Bit 0 is set if a size larger than 127 is found.
style
The styles for this font family at any of its sizes. The values in this field can also be represented with the Style data type:
                    TYPE
                        StyleItem =     (bold, italic, underline, outline,
                                         shadow, condense, extend);
                        Style = SET OF StyleItem;
nameOffset
The offset into the list of font names (indicated by the fontNamesHandle field of the PictInfo record) at which the name for this font family is stored. A font name, such as Geneva, is given to a font family to distinguish it from other font families.

When you are finished using the information returned in a FontSpec record, you should use the DisposeHandle procedure (described in Inside Macintosh: Memory ) to dispose of the memory allocated to it.

See the chapter "Font Manager" in Inside Macintosh: Text for more information about fonts.

PictInfo

When you use the GetPictInfo function (described on GetPictInfo ) to collect information about a picture, or when you use the GetPixMapInfo function (described on GetPixMapInfo ) to collect color information about a pixel map or bitmap, the function returns the information in a PictInfo record. When you gather this information for multiple pictures, pixel maps, or bitmaps, the RetrievePictInfo function (described on RetrievePictInfo ) also returns a PictInfo record containing this information.

Initially, all of the fields in a new PictInfo record are set to NIL . Relevant fields are set to appropriate values depending on the information you request using the Picture Utilities functions as described in this chapter.

The PictInfo record is defined as follows:

TYPE PictInfo =
RECORD
    version:                Integer;                {Picture Utilities version number}
    uniqueColors:           LongInt;                {total colors in survey}
    thePalette:             PaletteHandle;          {handle to a Palette record--NIL for }
                                                    { a bitmap in a basic graphics port}
    theColorTable:          CTabHandle;             {handle to a ColorTable record--NIL }
                                                    { for a bitmap in a basic graphics }
                                                    { port}
    hRes:                   Fixed;                  {best horizontal resolution (dpi)}
    vRes:                   Fixed;                  {best vertical resolution (dpi)}
    depth:                  Integer;                {greatest pixel depth}
    sourceRect:             Rect;                   {optimal bounding rectangle for }
                                                    { picture for display at resolution }
                                                    { specified in hRes and vRes fields}
    textCount:              LongInt;                {number of text strings in picture(s)}
    lineCount:              LongInt;                {number of lines in picture(s)}
    rectCount:              LongInt;                {number of rectangles in picture(s)}
    rRectCount:             LongInt;                {number of rounded rectangles in }
                                                    { picture(s)}
    ovalCount:              LongInt;                {number of ovals in picture(s)}
    arcCount:               LongInt;                {number of arcs and wedges in }
                                                    { picture(s)}
    polyCount:              LongInt;                {number of polygons in picture(s)}
    regionCount:            LongInt;                {number of regions in picture(s)}
    bitMapCount:            LongInt;                {number of bitmaps}
    pixMapCount:            LongInt;                {number of pixel maps}
    commentCount:           LongInt;                {number of comments in picture(s)}
    uniqueComments:         LongInt;                {number of different comments }
                                                    { (by ID) in picture(s)}
    commentHandle:          CommentSpecHandle;{handle to an array of CommentSpec }
                                                    { records for picture(s)}
    uniqueFonts:            LongInt;                {number of fonts in picture(s)}
    fontHandle:             FontSpecHandle;         {handle to an array of FontSpec }
                                                    { records for picture(s)}
    fontNamesHandle:        Handle;                 {handle to list of font names for }
                                                    { picture(s)}
    reserved1:              LongInt;
    reserved2:              LongInt;
END;
version
The version number of the Picture Utilities, currently set to 0.
uniqueColors
The number of colors in the picture specified to the GetPictInfo function, or the number of colors in the pixel map or bitmap specified to the GetPixMapInfo function, or the total number of colors for all the pictures, pixel maps, and bitmaps returned by the RetrievePictInfo function. The number of colors returned in this field is limited by the accuracy of the Picture Utilities' color bank for color storage. See "Application-Defined Routines," for information about the Picture Utility's color bank and about how you can create your own for selecting colors.
thePalette
A handle to the resulting Palette record if you specified to the GetPictInfo , GetPixMapInfo , or NewPictInfo function that colors be returned in a Palette record. That Palette record contains either the number of colors you specified to the function or--if there aren't that many colors in the pictures, pixel maps, or bitmaps--the number of colors found. Depending on the constant you pass in the verb parameter to the function, the Palette record contains either the most used or the widest range of colors in the pictures, pixel maps, and bitmaps. On Macintosh computers running basic QuickDraw only, this field is always returned as NIL . See the chapter "Palette Manager" in Inside Macintosh: Advanced Color Imaging for more information about Palette records.
theColorTable
A handle to the resulting ColorTable record if you specified to the GetPictInfo , GetPixMapInfo , or NewPictInfo function that colors be returned in a ColorTable record. If the pictures, pixel maps, or bitmaps contain fewer colors found than you specified to the function, the unused entries in the ColorTable record are filled with black. Depending on the constant you pass in the verb parameter to the function, the ColorTable record contains either the most used or the widest range of colors in the pictures, pixel maps, and bitmaps. The chapter "Color QuickDraw" in this book describes ColorTable records. On Macintosh computers running basic QuickDraw only, this field is always returned as NIL .
If a picture has more than 256 colors or has pixel depths of 32 bits, then Color QuickDraw translates the colors in the ColorTable record to 16-bit depths. In such a case, the returned colors might have a slight loss of resolution, and the uniqueColors field reflects the number of colors distinguishable at that pixel depth.
hRes
The horizontal resolution of the current picture, pixel map, or bitmap retrieved by the GetPictInfo or GetPixMapInfo function; the greatest horizontal resolution from all pictures, pixel maps, and bitmaps retrieved by the RetrievePictInfo function.
vRes
The vertical resolution of the current picture, pixel map, or bitmap retrieved by the GetPictInfo or GetPixMapInfo function; the greatest vertical resolution of all pictures, pixel maps, and bitmaps retrieved by the RetrievePictInfo function. Note that although the values of the hRes and vRes fields are usually the same, they don't have to be.
depth
The pixel depth of the picture specified to the GetPictInfo  function or the pixel map specified to the GetPixMapInfo function. When you use the RetrievePictInfo function, this field contains the deepest pixel depth of all pictures or pixel maps retrieved by the function.
sourceRect
The optimal bounding rectangle for displaying the picture at the resolution indicated by the hRes and vRes fields. The upper-left corner of the rectangle is always (0,0). Pictures created with the OpenCPicture function have the hRes , vRes , and sourceRect fields built into their Picture records. For pictures created by OpenPicture , the hRes and vRes fields are set to 72 dpi, and the source rectangle is calculated using the picFrame field of the Picture record for the picture.
textCount
The number of text strings in the picture specified to the GetPictInfo function, or the total number of text objects in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps specified to GetPixMapInfo or RetrievePictInfo , this field is set to 0.
lineCount
The number of lines in the picture specified to the GetPictInfo function, or the total number of lines in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
rectCount
The number of rectangles in the picture specified to the GetPictInfo function, or the total number of rectangles in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
rRectCount
The number of rounded rectangles in the picture specified to the GetPictInfo function, or the total number of rounded rectangles in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
ovalCount
The number of ovals in the picture specified to the GetPictInfo function, or the total number of ovals in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
arcCount
The number of arcs and wedges in the picture specified to the GetPictInfo function, or the total number of arcs and wedges in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
polyCount
The number of polygons in the picture specified to the GetPictInfo function, or the total number of polygons in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
regionCount
The number of regions in the picture specified to the GetPictInfo function, or the total number of regions in all the pictures retrieved by the RetrievePictInfo function. For pixel maps and bitmaps, this field is set to 0.
bitMapCount
The total number of bitmaps in the survey.
pixMapCount
The total number of pixel maps in the survey.
commentCount
The number of comments in the picture specified to the GetPictInfo function, or the total number of comments in all the pictures retrieved by the RetrievePictInfo function. This field is valid only if you specified to the GetPictInfo or NewPictInfo function that comments be returned in a CommentSpec record, described on CommentSpec . For pixel maps and bitmaps, this field is set to 0.
uniqueComments
The number of picture comments that have different IDs in the picture specified to the GetPictInfo function, or the total number of picture comments with different IDs in all the pictures retrieved by the RetrievePictInfo function. (The values for many common IDs are listed in Appendix B, "Using Picture Comments for Printing," in this book.) This field is valid only if you specify that comments be returned in a CommentSpec record. For pixel maps and bitmaps, this field is set to 0.
commentHandle
A handle to an array of CommentSpec records, described on CommentSpec . For pixel maps and bitmaps, this field is set to NIL .
uniqueFonts
The number of different fonts in the picture specified to the GetPictInfo function, or the total number of different fonts in all the pictures retrieved by the RetrievePictInfo function. For bitmap fonts, a font is a complete set of glyphs in one size, typeface, and style--for example, 12-point Geneva italic. For outline fonts, a font is a complete set of glyphs in one typeface and style--for example, Geneva italic.
This field is valid only if you specify that fonts be returned in a FontSpec record, which is described on FontSpec . For pixel maps and bitmaps, this field is set to 0.
fontHandle
A handle to a list of FontSpec records, described on FontSpec . For pixel maps and bitmaps, this field is set to NIL .
fontNamesHandle
A handle to the names of the fonts in the picture retrieved by the GetPictInfo function or the pictures retrieved by the RetrievePictInfo function. The offset to a particular name is stored in the nameOffset field of the FontSpec record for that font. A font name is a name, such as Geneva, given to one font family to distinguish it from other font families.

When you are finished with this information, be sure to dispose of it. You can dispose of Palette records by using the DisposePalette procedure (which is described in the chapter "Palette Manager" in Inside Macintosh: Advanced Color Imaging ). You can dispose of ColorTable records by using the DisposeCTable procedure (described in the chapter "Color QuickDraw" in this book). You can dispose of other allocations with the DisposeHandle procedure (described in Inside Macintosh: Memory ).


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next